package com.nbjtjc.safe.mapper.emg.handle;

import com.nbjtjc.safe.model.emg.handle.EmgHandlePublicGoods;
import com.nbjtjc.util.MyMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmgHandlePublicGoodsMapper extends MyMapper<EmgHandlePublicGoods> {

    @Select("select emg_handle_public_goods.* ,goodsCount AS count  " +
            " from emg_handle_public_goods  " +
            "LEFT JOIN (SELECT sum(emg_goods.count) goodsCount,goods_name " +
            "FROM emg_goods GROUP BY emg_goods.goods_name) gdt  " +
            "ON gdt.goods_name=emg_handle_public_goods.`name` " +
            "where handle_public_id=#{handlePublicId}")
    List<EmgHandlePublicGoods> findByHandlePublicId(@Param("handlePublicId") int handlePublicId);
}